package com.mi2021;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main2 {
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String words = br.readLine();
        final int[][] directions = {{1,0},{-1,0},{0,1},{0,-1}};
        final char[][] binaryWords = {{'A','B','C','E'},{'S','F','C','S'},{'A','D','E','E'}};
        int rows = binaryWords.length;
        int cols = binaryWords[0].length;
        boolean[][] isUsed = new boolean[rows][cols];
        boolean res = false;
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                if(back(binaryWords,isUsed,i,j,words,0,rows,cols,directions)){
                    res = true;
                    break;
                }
            }
        }
        System.out.println(res);

    }

    // 递归 + 回溯 检查
    private static boolean back(char[][] binaryWords, boolean[][] isUsed, int i, int j, String word, int index, int rows, int cols,int[][] directions) {


        if(isUsed[i][j] || word.charAt(index) != binaryWords[i][j]){
            return false;
        }

        if(index == word.length() - 1 && word.charAt(index) == binaryWords[i][j]){
            return true;
        }
        index++;
        isUsed[i][j] = true;
        boolean res = false;
        for (int[] direcrion:directions){
            int r = direcrion[0];
            int c = direcrion[1];
            int new_rol = r + i;
            int new_col = c + j;
            if(new_rol == rows){
                new_rol = 0;
            }else if(new_rol == -1){
                new_rol = rows - 1;
            }
            if(new_col == cols){
                new_col = 0;
            }else if(new_col == -1){
                new_col = cols - 1;
            }

            res |= back(binaryWords,isUsed,new_rol,new_col,word,index,rows,cols,directions);
        }
        index--;
        isUsed[i][j] = false;
        return res;
    }
}
